package definition.comparator;

import java.util.Comparator;

import definition.CustomClass;

/**
 * 适用于CustomClass的比较器
 * @author fidel
 */
public class CustomClassComparator implements Comparator<CustomClass> {
    /**
     * Comparator是外部比较器，被比较的两个对象所属类无需实现Comparable接口即可进行比较
     */
    @Override
    public int compare(CustomClass o1, CustomClass o2) {
        if (o1.getE() != o2.getE()) {
            return o1.getE() > o2.getE() ? 1 : -1;
        }
        if (o1.getF() != o2.getF()) {
            return o1.getF() > o2.getF() ? 1 : -1;
        }
        if (o1.getD() != o2.getD()) {
            return o1.getD() < o2.getD() ? 1 : -1;
        }
        return 0;
    }
}
